<?php
class SQLFilter
{
	public $field;
	public $comparator;
	public $value;
	
	public function __construct($field, $comparator=null, $value=null)
	{
		$this->field      = $field;
		$this->comparator = $comparator;
		$this->value      = $value;
		
		try
		{
			if (!empty($this->comparator) && empty($this->value))
				throw new Exception("Fatal: SQLFilter, provided \$comparator but no \$value");
		}
		catch(Exception $e)
		{
			$bt = debug_backtrace();
			die( $e->getMessage()." in ".$bt[0]['file']." at ".$bt[0]['line']." called from ".$bt[1]['file']." at ".$bt[1]['line'] );
		}
	}
	
	public function __get($property)
	{
		if ($property == 'length')
		{
			$count = 1;
			if (!empty($this->comparator)) $count++;
			
			return $count;
		}
	}
	
	public function __toString()
	{
		return "[object ".get_class($this)."]";
	}
}
?>
